package cn.org.spring.wechar.event.listener;

import cn.org.spring.wechar.bean.message.TextMessage;
import cn.org.spring.wechar.constant.EventType;
import cn.org.spring.wechar.event.Event;
import cn.org.spring.wechar.event.EventListener;

import java.util.Map;

/**
 * @author： 谢辉
 * @date： 2021/5/10
 * @email: xieh_mail@163.com
 * @description： view菜单事件推送
 * @modifiedBy：
 * @version: 1.0
 */
public class ViewListenter implements EventListener {
    @Override
    public String handleEvent(Event event) {
        Map<String, Object> message = event.getMessage();
        String eventType = message.get("Event").toString();
        if (EventType.eventType(eventType) == EventType.VIEW) {
            return TextMessage.ofSendMsg(message, "执行了点击view事件处理类，" + message.get("FromUserName").toString()).toXml();
        }
        return "success";
    }

    @Override
    public EventType getEvent() {
        return EventType.VIEW;
    }
}
